﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace NJL.Web
{
    public partial class SearchTopics :BasePageVisitor
    {
        NJL.BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtKeywords.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; ");
                Page.Title = Request.QueryString["keywords"] + "-农家乐网搜索结果";
                bind();
                txtKeywords.Text = Request.QueryString["keywords"];
            }
        }
        void bind()
        {
            DataSet ds = bllNews.GetList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and  NEWS_TITLE like  '%" + Request.QueryString["keywords"] + "%' or NEWS_SUBJECT_TITLE like '%" + Request.QueryString["keywords"] + "%' or NEWS_TAG like '%" + Request.QueryString["keywords"] + "%'");
            litCount.Text = ds.Tables[0].Rows.Count.ToString();
            if (ds.Tables[0].Rows.Count > 15)
            {
                string[] str = { "keywords" };
                pager.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptNews, 15, str);
            }
            else
            {
                rptNews.DataSource = ds;
                rptNews.DataBind();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Response.Redirect("SearchTopics.aspx?keywords=" + txtKeywords.Text.Trim());
        }
    }
}